package net.uman.service;

import java.util.List;

import net.uman.dao.PlateUserRelationsDao;
import net.uman.entity.PlateUserRelations;
import net.uman.framework.modules.orm.Page;
import net.uman.framework.modules.orm.PropertyFilter;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class PlateUserRelationsManager extends Manager {

	@Autowired
	private PlateUserRelationsDao plateUserRelationsDao;
	
	public PlateUserRelations get(Long id){
		return plateUserRelationsDao.get(id);
	}
	
	public Page<PlateUserRelations> getPlateUserRelationsPage(Page<PlateUserRelations> page,List<PropertyFilter> filters){
		return plateUserRelationsDao.findPage(page, filters);
	}
	
	public List<PlateUserRelations> getPlateUserRelationsList(List<PropertyFilter> filters){
		return plateUserRelationsDao.find(filters);
	}
	
	public void delete(Long id){
		plateUserRelationsDao.delete(id);
	}
	
	public void save(PlateUserRelations entity){
		plateUserRelationsDao.save(entity);
	}
	
	/**
	 * 确认版主
	 * @param id
	 * @return
	 */
	public boolean updateByComfired(long id){
		PlateUserRelations entity = get(id);
		if(entity == null || entity.getType() == PlateUserRelations.NORMAL){
			return false;
		}else{
			entity.setType(PlateUserRelations.NORMAL);
			plateUserRelationsDao.save(entity);
			return true;
		}
	}
}
